package com.danjoas.util;

import java.io.Reader;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

/**
 *
 * @author DanJoas
 */
public class MyBatisUitl {

    protected static final SqlSessionFactory SQL_SESSION_FACTORY;

    static {
        try {
            Reader reader = Resources.getResourceAsReader("com/danjoas/data/SqlMapConfig.xml");
            SQL_SESSION_FACTORY = new SqlSessionFactoryBuilder().build(reader);
        } catch (Exception e) {
            throw new RuntimeException("Error: " + e);
        }
    }

    public static SqlSessionFactory getSqlSessionFactory() {
        return SQL_SESSION_FACTORY;
    }
}
